<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title>岗位管理</title>
		<meta name="renderer" content="webkit">
		<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
		<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
		<link rel="stylesheet" type="text/css" href="assets/layui/css/layui.css" media="all" />
		<link rel="stylesheet" type="text/css" href="assets/css/all.css"  />
		<link rel="stylesheet" href="assets/zTree/css/zTreeStyle.css" type="text/css">
	</head
	<body>
		<div class="layui-fluid" >
			<div class="layui-form">
				<div class="layui-input-inline">
					<input style="width:260px" id="key1" type="text" name="title" lay-verify="" placeholder="请输入岗位名称或所属公司查询" autocomplete="off" class="layui-input">
				</div>
				<button class="layui-btn layui-btn-primary searchBtn" data-type="reload"><i class="layui-icon">&#xe615;</i>查询</button>
				<button class="layui-btn addBtn"><i class="layui-icon">&#xe654;</i>新增</button>
				<button class="layui-btn delBtn layui-btn-danger"><i class="layui-icon">&#xe640;</i>删除</button>
				<button class="layui-btn freshBtn layui-btn-green"><i class="layui-icon">&#x1002;</i>刷新</button>
			</div>
			<table class="layui-hide" id="car-type" lay-filter="carTypeTable"></table>
			<script type="text/html" id="checkInfor">
				<a class="layui-btn layui-btn-green layui-btn-xs" lay-event="edit"><i class="layui-icon">&#xe642;</i></a>
			</script>
			<script type="text/html" id="is_lock">
			    <input type="checkbox" name="is_lock" value="{{d.admin_id}}" lay-skin="switch" lay-text="正常|禁用" lay-filter="is_lock" {{ d.is_lock == 0 ? 'checked' : '' }}>
			</script>
		</div>
		<script src="assets/layui/layui.js" type="text/javascript"></script>
		<script src="assets/js/all.js" type="text/javascript"></script>
		<script type="text/javascript">
			layui.use(['table','layer','laypage','form'],function(){
				var table = layui.table,
					layer = layui.layer,
					laypage = layui.laypage,
					form = layui.form,
					$ = layui.$
					
					//车辆管理状态页面js					
					//方法级渲染
					var tableIn = table.render({
						elem: '#car-type',
						url: 'assets/data/account.json',
						cols: [
							[{
								type:'checkbox'
							}, {
								field: 'username',
								title: '岗位名称',
							},{
								field: 'department',
								title: '所属部门'
							},{
								field: 'creattime',
								title: '创建时间',
								minWidth: 110
							},{
								field:'number',
								title:'岗位人员',
							},{
								field:'tip',
								title:'备注',
							},{
								//fixed: 'right',
								align: 'center',
								toolbar: '#checkInfor',
								title:"操作"
							}]
						],
						page:true,
						limit: 10,
						limits:[10]
//						,done:function(res,curr,count){//res即为你接口返回的信息,curr 是当前页，count总页数
//							if(res.code == 0){
//								layer.msg(res.msg);
//							}
//							if(res.code == 1){
//								
//							}
//						}
					});

					$('.searchBtn').on('click', function() {
						var key1 = $('#key1').val();		
							//执行重载
							tableIn.reload({
//								if(key1==''&key2==''&key3=''){
//									layer.msg("请输入搜索内容");
//									return;
//								}
								page: {
									curr: 1 //重新从第 1 页开始
								},
								where: {
									key1: key1,								
								}
							});
					});
				
					//监听工具条
					table.on('tool(carTypeTable)', function(obj) {
						var data = obj.data;
						if(obj.event === 'edit') {
							var index = layer.open({
								type:2,
								title:'编辑岗位',
								area:["900px",'500px'],
								content:'editRole.html'
							});
						} 
						else if(obj.event === 'del') {
							layer.confirm('真的删除此行信息么', function(index) {
								obj.del();
								layer.close(index);
							});
						}
						//  else if(obj.event === 'edit'){
						//    layer.msg('ID：'+ data.id + ' 的查看操作');
						//  }
					});
					
					//监听新增岗位
					$(".addBtn").click(function(){
						var index = layer.open({
							type:2,
							title:'新增岗位',
							area:["900px",'500px'],
							content:'addNewRole.html'
						});
					});
					
					//删除信息
					$(".delBtn").click(function(){
						if($(".layui-form-checked").length<1){
							layer.msg("请选择要删除的信息")
						}else{
							var index = layer.confirm("确认删除选中信息吗？",function(){
								$(".layui-form-checked").parents("tr").remove();
								layer.close(index);
							})
						}
					});
	
			})
		</script>
	</body>

</html>